import { rcaNumberFormat,get_month_first,get_date } from './common.js'
import { commonTableOption } from './common.js'
export const startDate = get_month_first(0);
export const endDate = get_date(0);
const ccbCol = [
  {
    type: 'input',
    label: '唯一标识',
    prop: 'id',
    hide: true,
    display: false
  }, {
    type: 'input',
    label: '银行',
    prop: 'bankName'
  }, {
    type: 'input',
    label: '账号',
    prop: 'receiveAccount'
  }, {
    type: 'input',
    label: '账户名称',
    prop: 'receiveAccountName'
  }, {
    type: 'date',
    label: '记账日期',
    prop: 'recordTime',
    valueFormat: 'yyyy-MM-dd',
    searchValue: [startDate, endDate], 
    searchSpan: 12,
    searchRange: true,
    search: true,
  }, {
    type: 'date',
    label: '交易时间',
    prop: 'transactionTime',
  }, {
    type: 'input',
    showSummary: true,
    precision: 2,
    formatter: (row, value, label, column) => {
      return rcaNumberFormat(value, true)
    },
    label: '贷方发生额（收入）',
    prop: 'transactionAmoun',
  }, {
    type: 'input',
    label: '对方户名',
    prop: 'accountName',
	search: true
  }, {
    type: 'input',
    label: '备注',
    prop: 'remarks'
  }];

const bocCol = [
  {
    type: 'input',
    label: '唯一标识',
    prop: 'id',
    hide: true,
    display: false
  }, {
    type: 'input',
    label: '银行',
    prop: 'bankName'
  }, {
    type: 'input',
    label: '收款人账号',
    prop: 'receiveAccount'
  }, {
    type: 'input',
    label: '收款人名称',
    prop: 'receiveAccountName'
  }, {
    type: 'input',
    label: '收款人开户行名称',
    prop: 'receiveOpenAccountName'
  }, {
    type: 'date',
    label: '记账日期',
    prop: 'recordTime',
    searchSpan: 12,
    searchRange: true,
    search: true,
    valueFormat: 'yyyy-MM-dd',
  }, {
    type: 'date',
    label: '交易日期',
    prop: 'chinaTransactionTime',
  }, {
    type: 'input',
    showSummary: true,
    precision: 2,
    formatter: (row, value, label, column) => {
      return rcaNumberFormat(value, true)
    },
    label: '交易金额',
    prop: 'transactionAmoun',
  }, {
    type: 'input',
    label: '付款人名称',
    searchLabelWidth: 140,
    prop: 'accountName',
    search: true
  }, {
    type: 'input',
    label: '用途',
    prop: 'purpose'
  }];

export const tableOption = {
  ccb: {
    ...commonTableOption,
    height: '400px',
    column: ccbCol,
  },
  boc: {
    ...commonTableOption,
    height: '400px',
    column: bocCol,
  }
}

export const bankDic = [
  {
    label: '建行',
    value: 'ccb',
  },
  {
    label: '中行',
    value: 'boc',
  },
];

const tmpCcbCol = [
  ...ccbCol.map(c => ({ ...c, search: false, slot: c.prop === 'bankName' })), {
    type: 'input',
    label: '数据提醒',
    prop: 'errMsg',
    slot: true
  }];

const tmpBocCol = [
  ...bocCol.map(c => ({ ...c, search: false, slot: c.prop === 'bankName' })), {
    type: 'input',
    label: '数据提醒',
    prop: 'errMsg',
    slot: true
  }];

export const tmpTableOption = {
  ccb: {
    ...commonTableOption,
    refreshBtn: false,
    columnBtn: false,
    height: 500,
    column: tmpCcbCol,
  },
  boc: {
    ...commonTableOption,
    refreshBtn: false,
    columnBtn: false,
    height: 500,
    column: tmpBocCol,
  }
}

